package com.hzit.controller;

import com.hzit.service.IStudentService;
import com.hzit.dto.StudentDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：同步解决方案
 */
@Controller
@RequestMapping("/studentsync")
public class StudentControllerSync {

	@Autowired
	private IStudentService studentService;

	//1. 查询所有学生
	@GetMapping("/list")
	public String list(Model model){
		//1.1 查询学生
		List<StudentDTO> students = studentService.findAll();
		//1.2 将学生放到model中
		model.addAttribute("students",students);
		return "list";      // 物理视图：/WEB-INF/jsp/list.jsp
	}
}
